Streamline data from an n8n form into Google Sheet and Airtable
工作流概述
这是一个包含10个节点的复杂工作流,主要用于自动化处理各种任务。
工作流源代码
{
"id": "g25bM3Hj71T3ZVVe",
"meta": {
"instanceId": "21754f977ce20b07e6fe64be3fbc663f6e6f730423d6e46c6cd2bf5b5e70a383"
},
"name": "Streamline data from an n8n form into Google Sheet and Airtable",
"tags": [],
"nodes": [
{
"id": "32bd3bcb-7de7-4ca3-ba31-897e90f663b1",
"name": "n8n Form Trigger",
"type": "n8n-nodes-base.formTrigger",
"position": [
720,
-400
],
"webhookId": "c07c8eb6-cf56-4941-91cc-e3cb31c90b5c",
"parameters": {
"path": "c07c8eb6-cf56-4941-91cc-e3cb31c90b5c",
"options": {},
"formTitle": "Data Colleacation",
"formFields": {
"values": [
{
"fieldLabel": "What's your name ?",
"requiredField": true
},
{
"fieldLabel": "Where do you live ?",
"requiredField": true
},
{
"fieldLabel": "Your Email ?",
"requiredField": true
}
]
}
},
"typeVersion": 2
},
{
"id": "bf341165-2698-4f42-a92d-bc5e9a750bf1",
"name": "Extracting Date and Time Fields from 'submittedAt' Field",
"type": "n8n-nodes-base.code",
"position": [
920,
-400
],
"parameters": {
"jsCode": "// Loop over input items and separate date and time into two new fields
for (const item of $input.all()) {
// Extract date and time from 'submittedAt' field
const submittedAt = new Date(item.json['submittedAt']);
const date = submittedAt.toISOString().split('T')[0]; // Get date part
const time = submittedAt.toISOString().split('T')[1].split('.')[0]; // Get time part
// Remove the old 'submittedAt' field
delete item.json['submittedAt'];
// Add new 'Date' and 'Time' fields with respective values
item.json['Date'] = date;
item.json['Time'] = time;
}
return $input.all();
"
},
"typeVersion": 2
},
{
"id": "c9955ba1-0aa4-476b-b2ac-8a458b1547b3",
"name": "Format the Fields",
"type": "n8n-nodes-base.set",
"position": [
1100,
-400
],
"parameters": {
"fields": {
"values": [
{
"name": "Name",
"stringValue": "={{ $json['What\'s your name ?'] }}"
},
{
"name": "City",
"stringValue": "={{ $json['Where do you live ?'] }}"
},
{
"name": "Date",
"stringValue": "={{ $json.Date }}"
},
{
"name": "Time",
"stringValue": "={{ $json.Time }}"
},
{
"name": "Email",
"stringValue": "={{ $json['Your Email ?'] }}"
}
]
},
"include": "selected",
"options": {}
},
"typeVersion": 3.2
},
{
"id": "50e6057e-4b26-40f6-adc1-1721818f7a46",
"name": "Airtable",
"type": "n8n-nodes-base.airtable",
"position": [
1320,
-260
],
"parameters": {
"base": {
"__rl": true,
"mode": "id",
"value": "appIIeJ18fnPkNyNS"
},
"table": {
"__rl": true,
"mode": "id",
"value": "tblZvKuOMmtHnv5TH"
},
"columns": {
"value": {
"City": "={{ $json.City }}",
"Date": "={{ $json.Date }}",
"Name": "={{ $json.Name }}",
"Time": "={{ $json.Time }}",
"Email": "={{ $json.Email }}"
},
"schema": [
{
"id": "Name",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "City",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "City",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Email",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Date",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Time",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Time",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": []
},
"options": {},
"operation": "create"
},
"credentials": {
"airtableTokenApi": {
"id": "maZEeRzOyC8Q06Zf",
"name": "Airtable Personal Access Token account"
}
},
"typeVersion": 2
},
{
"id": "4f561bd8-a5dd-4ff2-9d3e-cdac6f762bd4",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
100,
-680
],
"parameters": {
"color": 5,
"width": 2256.3366317584496,
"height": 851.9587677224575,
"content": "### Workflow Description:
1. **n8n Form Trigger:**
- A trigger node that initiates the workflow when a form is submitted.
- Form fields include Name, City, and Email.
2. **Extracting Date and Time Fields from 'submittedAt' Field:**
- A code node that extracts Date and Time from the submittedAt field.
3. **Format the Fields:**
- Sets the format for the extracted fields (Name, City, Date, Time, Email).
4. **Airtable:**
- Creates a new record in Airtable with the formatted data.
- Includes columns for Name, City, Email, Time, and Date.
5. **Google Sheets:**
- Appends the formatted data to a Google Sheet.
- Includes columns for Name, City, Email, Date, and Time.
6. **Gmail:**
- Sends an email to the provided Email address.
- Subject: \"Testing Text Message Delivery\"
- Message: Customized message with Name placeholder.
7. **Gmail1:**
- Sends another email using a different template.
- Subject includes the Date field.
- Similar message content with a different subject line.
### Workflow Connections:
- n8n Form Trigger -> Extracting Date and Time Fields -> Format the Fields -> Google Sheets & Airtable -> Gmail
- Google Sheets -> Gmail1
This workflow collects data from a form submission, processes it to extract Date and Time fields, saves the formatted data to Google Sheets and Airtable, and sends customized emails to the submitter.
"
},
"typeVersion": 1
},
{
"id": "a0d53cb5-27c8-4dfb-a1ea-e2403bde1fc4",
"name": "Google Sheets",
"type": "n8n-nodes-base.googleSheets",
"position": [
1320,
-540
],
"parameters": {
"columns": {
"value": {
"City": "={{ $json.City }}",
"Date": "={{ $json.Date }}",
"Name": "={{ $json.Name }}",
"Time": "={{ $json.Time }}",
"Email": "={{ $json.Email }}"
},
"schema": [
{
"id": "Name",
"type": "string",
"display": true,
"required": false,
"displayName": "Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "City",
"type": "string",
"display": true,
"required": false,
"displayName": "City",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Email",
"type": "string",
"display": true,
"required": false,
"displayName": "Email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Date",
"type": "string",
"display": true,
"required": false,
"displayName": "Date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Time",
"type": "string",
"display": true,
"required": false,
"displayName": "Time",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": []
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Ss6AEwaXpAl54YQAQDf1z6SRyh6pj719-A9eOzf2Dv4/edit#gid=0",
"cachedResultName": "Page"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1Ss6AEwaXpAl54YQAQDf1z6SRyh6pj719-A9eOzf2Dv4",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Ss6AEwaXpAl54YQAQDf1z6SRyh6pj719-A9eOzf2Dv4/edit?usp=drivesdk",
"cachedResultName": "Streamline data from an n8n form into Google Sheet and Airtable"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "L5CnisK8R3BgVGcO",
"name": "Omar sheet"
}
},
"typeVersion": 4.2
},
{
"id": "de697574-f547-4374-86d9-c6d9f709c404",
"name": "Gmail",
"type": "n8n-nodes-base.gmail",
"position": [
1560,
-260
],
"parameters": {
"sendTo": "={{ $json.fields.Email }}",
"message": "=Dear {{ $json.fields.Name }} ..
Hey there! Just testing to see if this message goes through. Let me know if you receive it.
Thanks!
Support Team",
"options": {},
"subject": "Testing Text Message Delivery",
"emailType": "text"
},
"credentials": {
"gmailOAuth2": {
"id": "UJx4Tiq8WRtxWEIP",
"name": "Gmail Omar"
}
},
"typeVersion": 2.1
},
{
"id": "66677b7e-d053-4050-a65c-9c9f8f689646",
"name": "Gmail1",
"type": "n8n-nodes-base.gmail",
"position": [
1560,
-540
],
"parameters": {
"sendTo": "={{ $json.Email }}",
"message": "=Dear {{ $json.Name }} ..
Hey there! Just testing to see if this message goes through. Let me know if you receive it.
Thanks!
Support Team ",
"options": {},
"subject": "=Testing Text Message Delivery , ( {{ $json.Date }} ) ",
"emailType": "text"
},
"credentials": {
"gmailOAuth2": {
"id": "UJx4Tiq8WRtxWEIP",
"name": "Gmail Omar"
}
},
"typeVersion": 2.1
},
{
"id": "e440b4cb-6910-4bc7-b3df-7c14dd9c43a9",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1820,
-640
],
"parameters": {
"width": 510.8381838182147,
"height": 206.48715095387286,
"content": "### Links to Node Documentation:
1. [n8n Form Trigger Documentation](https://docs.n8n.io/nodes/n8n-nodes-base.formTrigger)
2. [Code Node Documentation](https://docs.n8n.io/nodes/n8n-nodes-base.code)
3. [Set Node Documentation](https://docs.n8n.io/nodes/n8n-nodes-base.set)
4. [Airtable Node Documentation](https://docs.n8n.io/nodes/n8n-nodes-base.airtable)
5. [Google Sheets Node Documentation](https://docs.n8n.io/nodes/n8n-nodes-base.googleSheets)
6. [Gmail Node Documentation](https://docs.n8n.io/nodes/n8n-nodes-base.gmail)
"
},
"typeVersion": 1
},
{
"id": "541ecd4c-22bc-4bc9-8364-ca73b4650092",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
680,
-640
],
"parameters": {
"width": 1105.0652438372836,
"height": 630.9350509674927,
"content": ""
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "de903de6-c793-4a64-9d3c-0ade08d6994e",
"connections": {
"Airtable": {
"main": [
[
{
"node": "Gmail",
"type": "main",
"index": 0
}
]
]
},
"Google Sheets": {
"main": [
[
{
"node": "Gmail1",
"type": "main",
"index": 0
}
]
]
},
"n8n Form Trigger": {
"main": [
[
{
"node": "Extracting Date and Time Fields from 'submittedAt' Field",
"type": "main",
"index": 0
}
]
]
},
"Format the Fields": {
"main": [
[
{
"node": "Google Sheets",
"type": "main",
"index": 0
},
{
"node": "Airtable",
"type": "main",
"index": 0
}
]
]
},
"Extracting Date and Time Fields from 'submittedAt' Field": {
"main": [
[
{
"node": "Format the Fields",
"type": "main",
"index": 0
}
]
]
}
}
}
功能特点
- 自动检测新邮件
- AI智能内容分析
- 自定义分类规则
- 批量处理能力
- 详细的处理日志
技术分析
节点类型及作用
- Formtrigger
- Code
- Set
- Airtable
- Stickynote
复杂度评估
配置难度:
维护难度:
扩展性:
实施指南
前置条件
- 有效的Gmail账户
- n8n平台访问权限
- Google API凭证
- AI分类服务订阅
配置步骤
- 在n8n中导入工作流JSON文件
- 配置Gmail节点的认证信息
- 设置AI分类器的API密钥
- 自定义分类规则和标签映射
- 测试工作流执行
- 配置定时触发器(可选)
关键参数
| 参数名称 | 默认值 | 说明 |
|---|---|---|
| maxEmails | 50 | 单次处理的最大邮件数量 |
| confidenceThreshold | 0.8 | 分类置信度阈值 |
| autoLabel | true | 是否自动添加标签 |
最佳实践
优化建议
- 定期更新AI分类模型以提高准确性
- 根据邮件量调整处理批次大小
- 设置合理的分类置信度阈值
- 定期清理过期的分类规则
安全注意事项
- 妥善保管API密钥和认证信息
- 限制工作流的访问权限
- 定期审查处理日志
- 启用双因素认证保护Gmail账户
性能优化
- 使用增量处理减少重复工作
- 缓存频繁访问的数据
- 并行处理多个邮件分类任务
- 监控系统资源使用情况
故障排除
常见问题
邮件未被正确分类
检查AI分类器的置信度阈值设置,适当降低阈值或更新训练数据。
Gmail认证失败
确认Google API凭证有效且具有正确的权限范围,重新进行OAuth授权。
调试技巧
- 启用详细日志记录查看每个步骤的执行情况
- 使用测试邮件验证分类逻辑
- 检查网络连接和API服务状态
- 逐步执行工作流定位问题节点
错误处理
工作流包含以下错误处理机制:
- 网络超时自动重试(最多3次)
- API错误记录和告警
- 处理失败邮件的隔离机制
- 异常情况下的回滚操作